package org.ogv.usada.models;

import org.ogv.OGV;
import org.ogv.CAssetManager.AssetDeclaration;

import com.badlogic.gdx.graphics.g2d.TextureRegion;


public class LevelDef {
	//Members that reflect to Json
	public String 			name;
	public String 			desc;
	public Byte[] 			customerTypes;
	public Byte[] 			illnessTypes;
	public Byte[] 			leafTypes;
	public float			time;
	public float[]			leafSpawnTime;	//0 = time, 1 = deviation
	public float[]			custSpawnTime; 	//0 = time, 1 = deviation
	public int[]			scores;
	public String[][]		bgFile;
	public String[][]		scoreBgFile;
	public String[][]		recipeBook;
	public String			music;
	public float[]			customerSeatPos;
	public Integer[]		leafSpawnCount;
	public AssetDeclaration assetDecl;
	public LevelRep			levelRep;
	
	public void resolve() {
		
	}

	/*
	 * return 1,2,3,4 - bronze silver gold perfect, 0 fail
	 */
	public int getScoreCategory(int score) {
		for(int i = scores.length - 1; i >= 0; --i) {
			if(score > scores[i])
				return i + 1;
		}
		return 0;
	}
	
	public static final class LevelRep {
		public String[] regPath; //region resource path
		public String[] pointPath; //pointer resource path
		public float[]	regPos;
		public float[]	pointPos;
		public float[]	starPos;
		
		private TextureRegion _regTex, _pointTex;
		public TextureRegion getRegTex() { return _regTex == null ? _regTex = OGV.asset.getTextureRegion(regPath) : _regTex; }
		public TextureRegion getPointTex() { return _pointTex == null ? _pointTex = OGV.asset.getTextureRegion(pointPath) : _pointTex; }
	}
}
